#ifndef PARSE_H
#define PARSE_H
#include "interpreter.h"

class Parse {
public:
    Parse();
    /* deallocate any memory */
    static void ParseCleanup(Interpreter *pc);

    /* parse a function definition and store it for later */
    static Value *ParseFunctionDefinition(Interpreter *pc, ParseState *parser,
                                   ValueType *returnType, char *identifier);


    /* copy the entire parser state */
    static void ParserCopy(ParseState *to, ParseState *from);

    /* copy where we're at in the parsing */
    static void ParserCopyPos(ParseState *to, ParseState *from);

    /* parse a statement */
    static ParseResult ParseStatement(Interpreter *pc, ParseState *parser,
                               int checkTrailingSemicolon);

    /* quick scan a source file for definitions */
    static void PicocParse(Interpreter *pc, const char *fileName, const char *source,
                    int sourceLen, int runIt, int cleanupNow, int cleanupSource,
                    int enableDebugger);

    /* parse interactively */
    static void PicocParseInteractiveNoStartPrompt(Interpreter *pc, int enableDebugger);

    /* parse interactively, showing a startup message */
    static void PicocParseInteractive(Interpreter *pc);

private:
    /* parse a statement, but only run it if condition is true */
    static ParseResult ParseStatementMaybeRun(Interpreter *pc, ParseState *parser,
                                              int condition, int checkTrailingSemicolon);
    /* count the number of parameters to a function or macro */
    static int ParseCountParams(ParseState *parser);
    /* parse an array initializer and assign to a variable */
    static int ParseArrayInitializer(Interpreter *pc, ParseState *parser,
                                     Value *newVariable, int doAssignment);
    /* assign an initial Value to a variable */
    static void ParseDeclarationAssignment(Interpreter *pc, ParseState *parser,
                                           Value *newVariable, int doAssignment);
    /* declare a variable or function */
    static int ParseDeclaration(ParseState *parser, LexToken token);
    /* parse a #define macro definition and store it for later */
    static void ParseMacroDefinition(ParseState *parser);
    /* parse a "for" statement */
    static void ParseFor(Interpreter *pc, ParseState *parser);
    /* parse a block of code and return what mode it returned in */
    static RunMode ParseBlock(Interpreter *pc, ParseState *parser, int absorbOpenBrace,
                              int condition);
    /* parse a typedef declaration */
    static void ParseTypedef(ParseState *parser);
    //Interpreter *pc;
    static int gEnableDebugger;
};
#endif //PARSE_H
